package com.atech.ebayadmin.system.util;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.atech.ebayadmin.common.util.StaticObj;


public class FilterUtil {
	private transient final static Log log = LogFactory.getLog(FilterUtil.class);
	private static FilterUtil core;
	private List<String> permissionList;
	
    public static FilterUtil getInstance() {
        if (null != core) {
            return core;
        }
        if (null == core) {
            core = new FilterUtil();
        }
        return core;
    }
    private FilterUtil() {
        log.info("开始初始化其他系统设置值");
        try{
        	
        	permissionList = StaticObj.systemService.listAllNeedFiltUrl();
        	for(String setUrl : permissionList){
        		log.info("需要校验的URL："+setUrl);
        	}
        }catch (Exception e) {
			e.printStackTrace();
		}
        log.info("初始化鉴权处理类完毕");
    }
    
    public boolean isNeedCheck(String reqUrl){
    	for(String setUrl : permissionList){
    		if(reqUrl.equals(setUrl)){
    			log.info(reqUrl + "需要进行权限校验!");
    			return true;
    		}
    	}
    	return false;
    }
    public boolean isHasPermission(Integer roleId,String reqUrl){
    	boolean isHasPmn =  StaticObj.systemService.isHasPermission(roleId, reqUrl);
    	return isHasPmn;
    }
}
